<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://www.springframework.org/security/tags" prefix="sec" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'test.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
    <!-- 权限标签 -->
    <!-- ifAllGranted，例子:只有当前用户同时拥有 ROLE_TEACHER 和 ROLE_USER 两个权限时，才能显示标签内部内容 -->
    <!-- ifAnyGranted，例子:如果当前用户拥有 ROLE_TEACHER 或 ROLE_USER 其中一个权限时，就能显示标签内部内容 --> 
    <!-- ifNotGranted，例子:如果当前用户没有 ROLE_TEACHER 时，才能显示标签内部内容 -->
  <body>
   <div>
       	<sec:authorize ifAnyGranted="ROLE_TEACHER">
       <% out.println("Hello JSP!");%>
       <% out.println("ROLE_TEACHER JSP!");%>
        </sec:authorize>
   </div>
    <div>
       	<sec:authorize ifAnyGranted="ROLE_ADMIN">
       <% out.println("Hello JSP!");%>
       <% out.println("ROLE_ADMIN JSP!");%>
        </sec:authorize>
   </div>
    <div>
       	<sec:authorize ifAnyGranted="ROLE_STUDENT">
       <% out.println("Hello JSP!");%>
       <% out.println("ROLE_STUDENT JSP!");%>
        </sec:authorize>
   </div>
  </body>
</html>
